home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / SciAn / src / ScianTemplates.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  10KB  |  458 lines

  1. /*ScianTemplates.c
  2.   Template routines for SciAn controls
  3.   Maintained by tl command
  4.   Eric Pepke
  5.   August 10, 1992
  6. */
  7.  
  8. #include "Scian.h"
  9. #include "ScianIDs.h"
  10. #include "ScianTypes.h"
  11. #include "ScianControls.h"
  12. #include "ScianButtons.h"
  13. #include "ScianSliders.h"
  14. #include "ScianTextBoxes.h"
  15. #include "ScianTitleBoxes.h"
  16. #include "ScianTemplates.h"
  17. #include "ScianTemplateLib.h"
  18. #include "ScianPerspec.h"
  19. #include "ScianColors.h"
  20. #include "ScianWindows.h"
  21. #include "ScianObjFunctions.h"
  22. #include "ScianStyle.h"
  23. #include "ScianScales.h"
  24. #include "ScianTrackControls.h"
  25.  
  26. #ifdef PROTO
  27. Bool GetTemplateBounds(TemplatePtr template, char *name, int *l, int *r, int *b, int *t)
  28. #else
  29. Bool GetTemplateBounds(template, name, l, r, b, t)
  30. TemplatePtr template;
  31. char *name;
  32. int *l, *r, *b, *t;
  33. #endif
  34. /*Gets the bounds of the given template, returns true if there.*/
  35. {
  36.     int k;
  37.     for (k = 0; ; ++k)
  38.     {
  39.     if (template[k] . name[0] == 0)
  40.     {
  41.         /*End of the line*/
  42.         return false;
  43.     }
  44.     if (0 == strcmp2(template[k] . name, name))
  45.     {
  46.         /*Bingo*/
  47.         *l = template[k] . l;
  48.         *r = template[k] . r;
  49.         *b = template[k] . b;
  50.         *t = template[k] . t;
  51.         return true;
  52.     }
  53.     }
  54. }
  55.  
  56. #ifdef PROTO
  57. ObjPtr TemplateSlider(TemplatePtr template, char *name, int style)
  58. #else
  59. ObjPtr TemplateSlider(template, name, style)
  60. TemplatePtr template;
  61. char *name;
  62. int style;
  63. #endif
  64. /*Returns a templated slider*/
  65. {
  66.     ObjPtr retVal;
  67.     int l, r, b, t;
  68.     if (GetTemplateBounds(template, name, &l, &r, &b, &t))
  69.     {
  70.     retVal = NewSlider(l, r, b, t, style, name);
  71.     return retVal;
  72.     }
  73.     else
  74.     {
  75.     char errStr[256];
  76.     sprintf(errStr, "Template '%s' not found", name);
  77.     ReportError("TemplateSlider", errStr);
  78.     }
  79. }
  80.  
  81. #ifdef PROTO
  82. ObjPtr TemplateTrackControl(TemplatePtr template, char *name, real low, real high)
  83. #else
  84. ObjPtr TemplateTrackControl(template, name, low, high)
  85. TemplatePtr template;
  86. char *name;
  87. real low, high;
  88. #endif
  89. /*Returns a templated track control*/
  90. {
  91.     ObjPtr retVal;
  92.     int l, r, b, t;
  93.     if (GetTemplateBounds(template, name, &l, &r, &b, &t))
  94.     {
  95.     retVal = NewTrackControl(l, r, b, t, name, low, high);
  96.     return retVal;
  97.     }
  98.     else
  99.     {
  100.     char errStr[256];
  101.     sprintf(errStr, "Template '%s' not found", name);
  102.     ReportError("TemplateTrackControl", errStr);
  103.     }
  104. }
  105.  
  106. #ifdef PROTO
  107. ObjPtr TemplateScale(TemplatePtr template, char *name, int orientation, Bool adj)
  108. #else
  109. ObjPtr TemplateScale(template, name, orientation, adj)
  110. TemplatePtr template;
  111. char *name;
  112. int orientation;
  113. Bool adj;
  114. #endif
  115. /*Returns a templated scale*/
  116. {
  117.     ObjPtr retVal;
  118.     int l, r, b, t;
  119.     if (GetTemplateBounds(template, name, &l, &r, &b, &t))
  120.     {
  121.     retVal = NewScale(l, r, b, t, orientation, adj, name);
  122.     return retVal;
  123.     }
  124.     else
  125.     {
  126.     char errStr[256];
  127.     sprintf(errStr, "Template '%s' not found", name);
  128.     ReportError("TemplateSlider", errStr);
  129.     }
  130. }
  131.  
  132. #ifdef PROTO
  133. ObjPtr TemplateIconButton(TemplatePtr template, char *name, int whichIcon, int hiColor, int style)
  134. #else
  135. ObjPtr TemplateIconButton(template, name, whichIcon, hiColor, style)
  136. TemplatePtr template;
  137. char *name;
  138. int whichIcon, hiColor, style;
  139. #endif
  140. /*Returns a templated icon button*/
  141. {
  142.     ObjPtr retVal;
  143.     int l, r, b, t;
  144.     if (GetTemplateBounds(template, name, &l, &r, &b, &t))
  145.     {
  146.     retVal = NewIconButton(l, r, b, t, whichIcon, hiColor, name, style);
  147.     return retVal;
  148.     }
  149.     else
  150.     {
  151.     char errStr[256];
  152.     sprintf(errStr, "Template '%s' not found", name);
  153.     ReportError("TemplateIconButton", errStr);
  154.     }
  155. }
  156.  
  157. #ifdef PROTO
  158. ObjPtr TemplateIconCorral(TemplatePtr template, char *name, ObjPtr superClass, int flags)
  159. #else
  160. ObjPtr TemplateIconCorral(template, name, superClass, flags)
  161. TemplatePtr template;
  162. char *name;
  163. int flags;
  164. ObjPtr superClass;
  165. #endif
  166. /*Returns a templated icon corral*/
  167. {
  168.     ObjPtr retVal;
  169.     int l, r, b, t;
  170.     if (GetTemplateBounds(template, name, &l, &r, &b, &t))
  171.     {
  172.     if (flags & BARRIGHT)
  173.     {
  174.     r += BARWIDTH + CORRALBARBORDER;
  175.     }
  176.     if (flags & BARLEFT)
  177.     {
  178.     l -= BARWIDTH + CORRALBARBORDER;
  179.     }
  180.  
  181.     if (flags & BARBOTTOM)
  182.     {
  183.     b -= BARWIDTH + CORRALBARBORDER;
  184.     }
  185.  
  186.     retVal = NewIconCorral(superClass, l, r, b, t, flags);
  187.     SetVar(retVal, NAME, NewString(name));
  188.     return retVal;
  189.     }
  190.     else
  191.     {
  192.     char errStr[256];
  193.     sprintf(errStr, "Template '%s' not found", name);
  194.     ReportError("TemplateIconCorral", errStr);
  195.     }
  196. }
  197.  
  198. #ifdef PROTO
  199. ObjPtr TemplateControlField(TemplatePtr template, char *name, int flags)
  200. #else
  201. ObjPtr TemplateControlField(template, name, flags)
  202. TemplatePtr template;
  203. char *name;
  204. int flags;
  205. #endif
  206. /*Returns a templated icon corral*/
  207. {
  208.     ObjPtr retVal;
  209.     int l, r, b, t;
  210.     if (GetTemplateBounds(template, name, &l, &r, &b, &t))
  211.     {
  212.     if (flags & BARRIGHT)
  213.     {
  214.     r += BARWIDTH + CORRALBARBORDER;
  215.     }
  216.     if (flags & BARLEFT)
  217.     {
  218.     l -= BARWIDTH + CORRALBARBORDER;
  219.     }
  220.  
  221.     if (flags & BARBOTTOM)
  222.     {
  223.     b -= BARWIDTH + CORRALBARBORDER;
  224.     }
  225.  
  226.     retVal = NewControlField(l, r, b, t, name, flags);
  227.     return retVal;
  228.     }
  229.     else
  230.     {
  231.     char errStr[256];
  232.     sprintf(errStr, "Template '%s' not found", name);
  233.     ReportError("TemplateControlField", errStr);
  234.     }
  235. }
  236.  
  237. #ifdef PROTO
  238. ObjPtr TemplateColorWheel(TemplatePtr template, char *name)
  239. #else
  240. ObjPtr TemplateColorWheel(template, name)
  241. TemplatePtr template;
  242. char *name;
  243. #endif
  244. /*Returns a templated color wheel*/
  245. {
  246.     ObjPtr retVal;
  247.     int l, r, b, t;
  248.     if (GetTemplateBounds(template, name, &l, &r, &b, &t))
  249.     {
  250.     retVal = NewColorWheel(l, r, b, t, name);
  251.     return retVal;
  252.     }
  253.     else
  254.     {
  255.     char errStr[256];
  256.     sprintf(errStr, "Template '%s' not found", name);
  257.     ReportError("TemplateSlider", errStr);
  258.     }
  259. }
  260.  
  261. #ifdef PROTO
  262. ObjPtr TemplateTitleBox(TemplatePtr template, char *name)
  263. #else
  264. ObjPtr TemplateTitleBox(template, name)
  265. TemplatePtr template;
  266. char *name;
  267. #endif
  268. /*Returns a templated title box*/
  269. {
  270.     ObjPtr retVal;
  271.     int l, r, b, t;
  272.     if (GetTemplateBounds(template, name, &l, &r, &b, &t))
  273.     {
  274.     retVal = NewTitleBox(l, r, b, t, name);
  275.     return retVal;
  276.     }
  277.     else
  278.     {
  279.     char errStr[256];
  280.     sprintf(errStr, "Template '%s' not found", name);
  281.     ReportError("TemplateTitleBox", errStr);
  282.     }
  283. }
  284.  
  285. #ifdef PROTO
  286. ObjPtr TemplateColorBar(TemplatePtr template, char *name)
  287. #else
  288. ObjPtr TemplateColorBar(template, name)
  289. TemplatePtr template;
  290. char *name;
  291. #endif
  292. /*Returns a templated color bar*/
  293. {
  294.     ObjPtr retVal;
  295.     int l, r, b, t;
  296.     if (GetTemplateBounds(template, name, &l, &r, &b, &t))
  297.     {
  298.     retVal = NewColorBar(l, r, b, t, name);
  299.     return retVal;
  300.     }
  301.     else
  302.     {
  303.     char errStr[256];
  304.     sprintf(errStr, "Template '%s' not found", name);
  305.     ReportError("TemplateColorBar", errStr);
  306.     }
  307. }
  308.  
  309. #ifdef PROTO
  310. ObjPtr TemplateRadioButton(TemplatePtr template, char *name)
  311. #else
  312. ObjPtr TemplateRadioButton(template, name)
  313. TemplatePtr template;
  314. char *name;
  315. #endif
  316. /*Returns a templated radio button*/
  317. {
  318.     ObjPtr retVal;
  319.     int l, r, b, t;
  320.     if (GetTemplateBounds(template, name, &l, &r, &b, &t))
  321.     {
  322.     retVal = NewRadioButton(l, r, b, t, name);
  323.     return retVal;
  324.     }
  325.     else
  326.     {
  327.     char errStr[256];
  328.     sprintf(errStr, "Template '%s' not found", name);
  329.     ReportError("TemplateRadioButton", errStr);
  330.     }
  331. }
  332.  
  333. #ifdef PROTO
  334. ObjPtr TemplateButton(TemplatePtr template, char *name)
  335. #else
  336. ObjPtr TemplateButton(template, name)
  337. TemplatePtr template;
  338. char *name;
  339. #endif
  340. /*Returns a templated button*/
  341. {
  342.     ObjPtr retVal;
  343.     int l, r, b, t;
  344.     if (GetTemplateBounds(template, name, &l, &r, &b, &t))
  345.     {
  346.     retVal = NewButton(l, r, b, t, name);
  347.     return retVal;
  348.     }
  349.     else
  350.     {
  351.     char errStr[256];
  352.     sprintf(errStr, "Template '%s' not found", name);
  353.     ReportError("TemplateButton", errStr);
  354.     }
  355. }
  356.  
  357. #ifdef PROTO
  358. ObjPtr TemplatePerspecControl(TemplatePtr template, char *name)
  359. #else
  360. ObjPtr TemplatePerspecControl(template, name)
  361. TemplatePtr template;
  362. char *name;
  363. #endif
  364. /*Returns a templated PerspecControl*/
  365. {
  366.     ObjPtr retVal;
  367.     int l, r, b, t;
  368.     if (GetTemplateBounds(template, name, &l, &r, &b, &t))
  369.     {
  370.     retVal = NewPerspecControl(l, r, b, t, name);
  371.     return retVal;
  372.     }
  373.     else
  374.     {
  375.     char errStr[256];
  376.     sprintf(errStr, "Template '%s' not found", name);
  377.     ReportError("TemplatePerspecControl", errStr);
  378.     }
  379. }
  380.  
  381.  
  382. #ifdef PROTO
  383. ObjPtr TemplateCheckBox(TemplatePtr template, char *name, Bool value)
  384. #else
  385. ObjPtr TemplateCheckBox(template, name, value)
  386. TemplatePtr template;
  387. char *name;
  388. Bool value;
  389. #endif
  390. /*Returns a templated check box*/
  391. {
  392.     ObjPtr retVal;
  393.     int l, r, b, t;
  394.     if (GetTemplateBounds(template, name, &l, &r, &b, &t))
  395.     {
  396.     retVal = NewCheckBox(l, r, b, t, name, value);
  397.     return retVal;
  398.     }
  399.     else
  400.     {
  401.     char errStr[256];
  402.     sprintf(errStr, "Template '%s' not found", name);
  403.     ReportError("TemplateCheckBox", errStr);
  404.     }
  405. }
  406.  
  407. #ifdef PROTO
  408. ObjPtr TemplateTextBox(TemplatePtr template, char *name, int style, char *value)
  409. #else
  410. ObjPtr TemplateTextBox(template, name, style, value)
  411. TemplatePtr template;
  412. char *name;
  413. int style;
  414. char *value;
  415. #endif
  416. /*Returns a templated text box*/
  417. {
  418.     ObjPtr retVal;
  419.     int l, r, b, t;
  420.     if (GetTemplateBounds(template, name, &l, &r, &b, &t))
  421.     {
  422.     retVal = NewTextBox(l, r, b, t, style, name, value);
  423.     return retVal;
  424.     }
  425.     else
  426.     {
  427.     char errStr[256];
  428.     sprintf(errStr, "Template '%s' not found", name);
  429.     ReportError("TemplateTextBox", errStr);
  430.     }
  431. }
  432.  
  433. #ifdef PROTO
  434. ObjPtr TemplatePanel(TemplatePtr template, char *name)
  435. #else
  436. ObjPtr TemplatePanel(template, name)
  437. TemplatePtr template;
  438. char *name;
  439. #endif
  440. /*Returns a templated panel*/
  441. {
  442.     ObjPtr retVal;
  443.     int l, r, b, t;
  444.     if (GetTemplateBounds(template, name, &l, &r, &b, &t))
  445.     {
  446.     retVal = NewPanel(greyPanelClass, l, r, b, t);
  447.     SetVar(retVal, NAME, NewString(name));
  448.     return retVal;
  449.     }
  450.     else
  451.     {
  452.     char errStr[256];
  453.     sprintf(errStr, "Template '%s' not found", name);
  454.     ReportError("TemplateTextBox", errStr);
  455.     }
  456. }
  457.  
  458.